package io.imp.modules.itcs.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import io.imp.commons.dynamic.datasource.annotation.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.imp.common.utils.PageUtils;
import io.imp.common.utils.Query;

import io.imp.modules.itcs.dao.CppRoadConfDao;
import io.imp.modules.itcs.entity.CppRoadConfEntity;
import io.imp.modules.itcs.service.CppRoadConfService;

@Slf4j
@Service("cppRoadConfService")
@DataSource("dynamic")
public class CppRoadConfServiceImpl extends ServiceImpl<CppRoadConfDao, CppRoadConfEntity> implements CppRoadConfService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CppRoadConfEntity> page = this.page(
                new Query<CppRoadConfEntity>().getPage(params),
                new QueryWrapper<CppRoadConfEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public CppRoadConfEntity getById(Serializable id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public boolean save(CppRoadConfEntity entity) {
        return this.retBool(this.baseMapper.insert(entity));
    }

    @Override
    public boolean updateById(CppRoadConfEntity entity) {
        return this.retBool(this.baseMapper.updateById(entity));
    }

    @Override
    public boolean removeByIds(Collection<? extends Serializable> idList) {
        return SqlHelper.delBool(this.baseMapper.deleteBatchIds(idList));
    }
}
